package fenapple;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class FenAplle {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        int sum=0;
        int temp=0;
        for (int j = 0; j < i; j++) {
            int m=sc.nextInt();
            list.add(m);
            sum=sum+m;
            temp=temp^m;
        }
        if(temp!=0)
            System.out.println(-1);
        else{
            Integer min = Collections.min(list);
            System.out.println(sum-min);
        }

    }
}
